package com.weiyuwqj.controller.xianfeng.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;


/**
 * 自定义切面，和自定义注解联合使用完成日志收集
 * @author Administrator
 *
 */
@Component
@Aspect
public class LogAop {

	@Autowired
	private HttpServletRequest request;

/*	@Autowired
	private BusXfOrderServer busXfOrderServer;*/

	@Pointcut(value="@annotation(XfAnnotation)")
	public void pointCut(){

	}
/*

	@Around(value="pointCut()&&@annotation(xfAnnotation)")
	public Object aroundAdvice(ProceedingJoinPoint pjp, XfAnnotation xfAnnotation) throws Throwable{
		//创建回调收集类
		BusXfOrder busXfOrder = new BusXfOrder();

		// 获取参数
		 Object[] objs =pjp.getArgs();
		//request参数
		Map reqMap = (Map)objs[0];
		if(reqMap!=null){
			busXfOrder.setRequestJson(JsonUtils.toJson(reqMap));
		}

		//先锋回调参数
		Map paramMap = (Map)objs[1];
		if(paramMap!=null){
			busXfOrder.setParamJson(JsonUtils.toJson(paramMap));
		}

		//用户id
		Object userId =objs[2];
		if(userId!=null){
			busXfOrder.setUserId(Integer.parseInt(userId.toString()));
		}

		//项目id
		Object itemId =objs[3];
		if(itemId!=null){
			busXfOrder.setItemId(Integer.parseInt(itemId.toString()));
		}

		//操作金额
		Object amount =objs[4];
		if(amount!=null){
			busXfOrder.setAmount(new BigDecimal(amount.toString()));
		}

		//订单号
		Object orderNo  = objs[5];
		if(orderNo!=null){
			busXfOrder.setOrderNo(orderNo.toString());
	}

		//期数
		Object period = objs[6];
		if(period!=null){
			busXfOrder.setPeriod(Integer.parseInt(period.toString()));
		}

		//类型
		Object type = objs[7];
		if(type!=null){
			busXfOrder.setType(Integer.parseInt(type.toString()));
		}

		//待收id
		Object collectId = objs[8];
		if(collectId!=null){
			busXfOrder.setCollectId(Integer.parseInt(collectId.toString()));
		}

		//状态
		Object status = objs[9];
		if(status!=null){
			busXfOrder.setStatus(Integer.parseInt(status.toString()));
		}

		if(reqMap!=null){
//			 往数据库中添加数据
			busXfOrder.setAddtime(new Date());
			busXfOrderServer.save(busXfOrder);
		}else{
			//往数据库中更新数据
			busXfOrderServer.uptParam(busXfOrder);
		}

		return pjp.proceed() ;

	}
*/



}
